import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    OnGrade:global.sessionStorage.getItem('OnGrade'),
    OnName:global.sessionStorage.getItem('OnName'),
    tel:global.sessionStorage.getItem('tel'),
    code:global.sessionStorage.getItem('code'),
    cookie:global.sessionStorage.getItem('cookie'),
    classa:global.sessionStorage.getItem('classa'),
    classb:global.sessionStorage.getItem('classb'),
    classc:global.sessionStorage.getItem('classc'),
    athleteid:global.sessionStorage.getItem('athleteid'),
    athletename:global.sessionStorage.getItem('athletename'),
    totalPercentage: 0
  },
  mutations: {
    clearTotal(state) {
      state.totalPercentage = 0
    },
    addTotal(state) {
      state.totalPercentage += 1
    },
    setGrade(state,grade){
      state.OnGrade=grade
      global.sessionStorage.setItem('OnGrade',grade)
    },
    setTel(state,tel){
      state.tel=tel
      global.sessionStorage.setItem('tel',tel)
    },
    setCode(state,code){
      state.code=code
      global.sessionStorage.setItem('code',code)
    },
    setCookie(state,cookie){
      state.cookie=cookie
      global.sessionStorage.setItem('cookie',cookie)
    },
    setClassA(state,ca){
      state.classa=ca
      global.sessionStorage.setItem('classa',ca)
    },
    setClassB(state,cb){
      state.classb=cb
      global.sessionStorage.setItem('classb',cb)
    },
    setClassC(state,cc){
      state.classc=cc
      global.sessionStorage.setItem('classc',cc)
    },
    setAthlete(state,id){
      state.athleteid=id
      global.sessionStorage.setItem('athleteid',id)
    },
    setAthleteName(state,name){
      state.athletename=name
      global.sessionStorage.setItem('athletename',name)
    },
  },
  actions: {
  },
  modules: {
  }
})
